<!DOCTYPE html>
<html lang="en">
<head>
    <include file="Public/h/head.html" title="账号管理" main="" key=""/>
</head>

<body class="overflow-hidden">
<div class="wrapper preload">
    <!--顶栏-->
    <include file="Public/h/nav.html"/>

    <!-- 菜单 -->
    <include file="Public/h/menu.html"/>

    <!--主要内容-->
    <div class="main-container">
        <div class="padding-md">
            <!--标题-->
            <div class="jw-box">
                <div class="page-title text-primary">
                    <b>账号管理</b>
                </div>
            </div>
            <div class="jw-box">
                <form>
                    <input type="text" name="name" placeholder="姓名">
                    <input type="text" name="uname" placeholder="账号">
                    <button>搜索</button>
                    <a class="btn btn-sm btn-primary pull-right" onclick="$('#add-mb').modal()">新增账号</a>
                </form>
            </div>
            <div class="jw-box">
                <table class="table table-bordered table-hover">
                    <tr>
                        <th>#</th>
                        <th>姓名</th>
                        <th>账号</th>
                        <th>最后IP</th>
                        <th>角色</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    <foreach name="user" item="vo">
                        <tr>
                            <td><{$vo.id}></td>
                            <td><{$vo.name}></td>
                            <td><{$vo.username}></td>
                            <td><{$vo.last_login_ip}></td>
                            <td><{$vo.role_name}></td>
                            <td><{$vo.create_time}></td>
                            <td>
                                <a class="text-danger" onclick="delTip('<{$vo.id}>')">删除</a>
                                <a class="text-primary change-btn" data-id="<{$vo.id}>" data-name="<{$vo.name}>" data-user="<{$vo.username}>" data-role="<{$vo.role_id}>">修改</a>
                                <a class="text-success pw" data-id="<{$vo.id}>">密码</a>
                            </td>
                        </tr>
                    </foreach>
                </table>
            </div>
            <!--导入分页-->
            <include file="Public/h/page.html"/>
        </div><!-- ./padding-md -->
    </div><!-- /main-container -->

    <!--删除提醒-->
    <div class="modal fade" id="del-mb">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">提示</h4>
                </div>
                <div class="modal-body">
                    <p>你确定删除该账号？</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <a id="sure-del-btn" class="btn btn-primary">非常确定</a>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <!--新增账号-->
    <div class="modal fade" id="add-mb">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">新增账号</h4>
                </div>
                <form action="__CONTROLLER__/add" method="post">
                    <div class="modal-body">
                        <div class="form-group m-bottom-md">
                            <label>登录账号</label>
                            <input type="text" name="username" class="form-control" required>
                        </div>
                        <div class="form-group m-bottom-md">
                            <label>姓名</label>
                            <input type="text" name="name" class="form-control" required>
                        </div>
                        <div class="form-group m-bottom-md">
                            <label>角色</label>
                            <select name="role_id" class="form-control" required>
                                <option value="">请选择...</option>
                                <foreach name="role" item="vo">
                                    <option value="<{$vo.id}>"><{$vo.name}></option>
                                </foreach>
                            </select>
                        </div>
                        <div class="form-group m-bottom-md">
                            <label>密码</label>
                            <input type="text" name="password" class="form-control" required>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button class="btn btn-primary">添加账号</button>
                    </div>
                </form>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <!--修改账号-->
    <div class="modal fade" id="upd-mb">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">修改账号</h4>
                </div>
                <form action="__CONTROLLER__/upd" method="post">
                    <div class="modal-body">
                        <div class="form-group m-bottom-md">
                            <label>登录账号</label>
                            <input type="hidden" id="id" name="id">
                            <input type="text" id="user" name="username" class="form-control" required>
                        </div>
                        <div class="form-group m-bottom-md">
                            <label>姓名</label>
                            <input type="text" id="name" name="name" class="form-control" required>
                        </div>
                        <div class="form-group m-bottom-md">
                            <label>角色</label>
                            <select id="role" name="role_id" class="form-control" required>
                                <option value="">请选择...</option>
                                <foreach name="role" item="vo">
                                    <option value="<{$vo.id}>"><{$vo.name}></option>
                                </foreach>
                            </select>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button class="btn btn-primary">修改账号</button>
                    </div>
                </form>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <!--重置密码-->
    <div class="modal fade" id="pw-mb">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">重置密码</h4>
                </div>
                <form action="__CONTROLLER__/upd" method="post">
                    <div class="modal-body">
                        <div class="form-group m-bottom-md">
                            <label>新密码</label>
                            <input type="hidden" id="the_id" name="id">
                            <input type="text" id="pw" name="password" class="form-control" required>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button class="btn btn-primary">重置密码</button>
                    </div>
                </form>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <include file="Public/h/foot.html"/>
</div><!-- /wrapper -->
<a href="#" class="scroll-to-top hidden-print"><i class="fa fa-chevron-up fa-lg"></i></a>
<include file="Public/h/js.html"/>
<script>
    function delTip($id) {
        $('#sure-del-btn').attr('href','__CONTROLLER__/del/id/'+$id);
        $('#del-mb').modal();
    }
    $('.change-btn').click(function () {
        $('#id').val($(this).data('id'));
        $('#name').val($(this).data('name'));
        $('#user').val($(this).data('user'));
        $('#role').val($(this).data('role'));
        $('#upd-mb').modal();
    });
    $('.pw').click(function () {
        $('#the_id').val($(this).data('id'));
        $('#pw-mb').modal();
    });
</script>
</body>
</html>
